package com.ruoyi.thgd.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.thgd.domain.ThgdZdFile;
import com.ruoyi.thgd.service.IThgdZdFileService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * zdFileController
 *
 * @author chenhs
 * @date 2024-09-30
 */
@RestController
@RequestMapping("/thgd/file")
public class ThgdZdFileController extends BaseController
{
    @Autowired
    private IThgdZdFileService thgdZdFileService;

    /**
     * 查询zdFile列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ThgdZdFile thgdZdFile)
    {
        startPage();
        List<ThgdZdFile> list = thgdZdFileService.selectThgdZdFileList(thgdZdFile);
        return getDataTable(list);
    }

    /**
     * 导出zdFile列表
     */
    @Log(title = "zdFile", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ThgdZdFile thgdZdFile)
    {
        List<ThgdZdFile> list = thgdZdFileService.selectThgdZdFileList(thgdZdFile);
        ExcelUtil<ThgdZdFile> util = new ExcelUtil<ThgdZdFile>(ThgdZdFile.class);
        util.exportExcel(response, list, "zdFile数据");
    }

    /**
     * 获取zdFile详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(thgdZdFileService.selectThgdZdFileById(id));
    }

    /**
     * 新增zdFile
     */
    @Log(title = "zdFile", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ThgdZdFile thgdZdFile)
    {
        return toAjax(thgdZdFileService.insertThgdZdFile(thgdZdFile));
    }

    /**
     * 修改zdFile
     */
    @Log(title = "zdFile", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ThgdZdFile thgdZdFile)
    {
        return toAjax(thgdZdFileService.updateThgdZdFile(thgdZdFile));
    }

    /**
     * 删除zdFile
     */
    @Log(title = "zdFile", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(thgdZdFileService.deleteThgdZdFileByIds(ids));
    }
}
